
<template>
    <div class="initiateInvitationPageBox">
        <!-- 搜索栏 start-->
        <div class="invite-sub">
            <img class="invite-logo" src="../../static/image/icon-title.png" alt="">
            <span class="inviteSearch">
              <input type="text" placeholder="搜索">
                <img src="../../static/image/sousuo.png" alt="">
            </span>
        </div>
        <!-- 搜索栏 end-->
        <!-- 导航跳转栏 start-->
        <adminHeader></adminHeader>
        <!-- 导航跳转栏 end-->
        <!-- 单堂课程 start-->
        <div class="courseTable">
            <table>
                <thead>
                    <tr>
                        <th>课程名称</th>
                        <th>报名截止时间</th>
                        <th>开课日期</th>
                        <th>开课时间</th>
                        <th>组数</th>
                        <th>轮数</th>
                        <th>人数</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="courseList in courseLists" :key="courseList.courseId">
                        <td>{{courseList.courseName}}</td>
                        <td>{{courseList.applyEndTime | timeToYMDHMS}}</td>
                        <td>{{courseList.startTime | timeToYMD}}</td>
                        <td>{{courseList.startTime | timeToHMS}}</td>
                        <td>{{courseList.teamsNumber}}</td>
                        <td>{{courseList.roundNumber}}</td>
                        <td>{{courseList.numberOfPeople}}</td>
                        <td>
                            <router-link :to="{name:'has-invite-participants',params:{courseId:courseList.courseId}}">已接受邀请名单</router-link>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- 单堂课程 end-->
        <!-- 学员列表 start-->
        <div class="studentLists" v-show="!studentsAll">
            <!-- 学员导航栏 start-->
            <div class="studentNav">
                <el-button class="navImport" type="text" @click="dialogImport = true"><img src="../../static/image/moban.png" alt="">批量导入学员</el-button>
                <!-- <el-button class="navImport navInvite" type="text"  @click="dialogHasInvite = true"><img src="../../static/image/white-sure.png" alt="">邀请已有学员</el-button> -->
                <!-- <router-link :to="{name:'invite-has-student'}" class="navInvite" type="text"><img src="../../static/image/white-sure.png" alt="">邀请已有学员</router-link> -->
                <span class="navInvite" @click="addStudents()"><img src="../../static/image/white-sure.png" alt="">邀请已有学员</span>
            </div>
            <!-- 学员导航栏 end-->
            <!-- 学员列表详情 start-->
            <div class="studentItems">
                <div class="studentItem" v-for="(stuList,index) in teamLists" :key="index">
                
                    <table>
                        <thead>
                            <tr>
                                <th></th>
                                <th>姓名</th>
                                <th>手机</th>
                                <th>性别</th>
                                <th>子公司/部门</th>
                                <th>职位</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="(stuData,sindex) in stuList.memberLists" :key="sindex">
                                <td>{{stuData.num}}</td>
                                <td><input v-model="stuData.name" type="text"></td>
                                <td>
                                    <input v-model="stuData.inviteMemberMobile" type="text" @change="blurValidator(stuData.inviteMemberMobile,teamLists,$event)">
                                    <div class="emptyTip2">
                                        
                                        <!-- <img src="../../static/image/failure.png" alt=""> -->
                                    </div>
                                </td>
                                <td>
                                    <select v-model="stuData.gender">
                                        <!-- <option v-for="sexList in stuData.sexLists" :key="sexList.index" v-bind:value="sexList.id">{{sexList.text}}</option>                 -->
                                        <option value="男">男</option>
                                        <option value="女">女</option>
                                    </select>
                                </td>
                                <td><input v-model="stuData.department" type="text"></td>
                                <td>
                                    <select v-model="stuData.position" :id="'position'+index+sindex">
                                        <option v-for="(positionList,index) in positionLists" :key="index" v-bind:value="positionList.id">{{positionList.positionName}}</option>                
                                    </select>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 学员列表详情 end-->
            <div class="itemSure"><el-button @click="invite()"><img src="../../static/image/icon-sign.png" alt="">邀 请</el-button></div>
        </div>
        <!-- 学员列表 end-->
        <!-- 批量导入学员Dialog start-->
        <el-dialog class="importCode"
        title="使用模板导入"
        :visible.sync="dialogImport">
        <div class="import">
            <h4><i></i>导入学员账号</h4>
            <!-- 上传文件 start -->
            <div class="upfile">
                <el-upload
                class="upload-demo"
                action="/api/admin/inviteCourseMemberExcel"
                :on-success="handleSuccess"
                :before-upload="beforeAvatarUpload"
                :show-file-list = "true">   
                    <div class="leftSide">上传文件</div>           
                    <el-button class="uploadImport" size="small" type="primary" id="uploadImport"><img src="../../static/image/huixingzhen.png" alt="">上传</el-button>
                </el-upload>
            </div>
            <!-- 上传文件 end -->
            <div class="importPrompts">
                <div class="promptsTip" v-if="promptsTip"><img src="../../static/image/failure.png" alt=""> 上传文件只能是xls、xlsx格式！</div>
                <div class="promptContent">
                    <p>请依照下列指示操作：</p>
                    <p>1. 点击下载<a href="http://p92g708lv.bkt.clouddn.com/%E9%82%80%E8%AF%B7%E8%AF%BE%E7%A8%8B%E5%AD%A6%E5%91%98%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx">批量导入模版</a>下载模板</p>
                    <p>2. 编辑学员名单</p>
                    <p>3. 上传编辑过后得xml文件</p>
                </div>
            </div>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="importStudent">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 批量导入学员Dialog end-->
        <!-- 导入学员失败Dialog start-->
        <el-dialog class="importCode"
        title="下列学员导入失败"
        :visible.sync="dialogFailure">
        <div class="import">
            <table class="importTable">
                <thead>
                    <tr>
                        <th>手机号</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>职位</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="failureList in failureLists" :key="failureList.index">
                        <td>{{failureList.phone}}</td>
                        <td>{{failureList.name}}</td>
                        <td>{{failureList.age}}</td>
                        <td>{{failureList.sex}}</td>
                        <td>{{failureList.position}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="dialogFailure = false">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 导入学员失败Dialog end-->
        <!-- 导入学员手机号重复Dialog start-->
        <el-dialog class="importCode"
        title="手机号重复"
        :visible.sync="dialogRepeat">
        <div class="import">
            <table class="importTable">
                <thead>
                    <tr>
                        <th>手机号</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>职位</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="repeatList in repeatLists" :key="repeatList.index">
                        <td>{{repeatList.phone}}</td>
                        <td>{{repeatList.name}}</td>
                        <td>{{repeatList.age}}</td>
                        <td>{{repeatList.sex}}</td>
                        <td>{{repeatList.position}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="dialogRepeat = false">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 导入学员手机号重复Dialog end-->
        <!-- 邀请已有学员Dialog start-->
        <el-dialog class="importCode"
        title="您已经邀请下列学员"
        :visible.sync="dialogHasInvite">
        <div class="import">
            <table class="importTable">
                <thead>
                    <tr>
                        <th>手机号</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>职位</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="inviteList in inviteLists" :key="inviteList.index">
                        <td>{{inviteList.phone}}</td>
                        <td>{{inviteList.name}}</td>
                        <td>{{inviteList.age}}</td>
                        <td>{{inviteList.sex}}</td>
                        <td>{{inviteList.position}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="hasInvite()">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 邀请已有学员Dialog end-->
        <!-- 邀请已有学员邀请码Dialog start-->
        <el-dialog class="importCode"
        title="您已经邀请下列学员"
        :visible.sync="dialogCodeInvite">
        <div class="import">
            <table class="importTable">
                <thead>
                    <tr>
                        <th>手机号</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>职位</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="inviteList in inviteLists" :key="inviteList.index">
                        <td>{{inviteList.phone}}</td>
                        <td>{{inviteList.name}}</td>
                        <td>{{inviteList.age}}</td>
                        <td>{{inviteList.sex}}</td>
                        <td>{{inviteList.position}}</td>
                    </tr>
                </tbody>
            </table>
            <div class="codeInvite">
                <p class="codeNumber">注册邀请码：<span>{{inviteCodeNumber}}</span></p>
                <div class="codeImg">
                    <img :src="inviteCode" alt="">
                    <div class="codeCopy">
                        <p>复制链接</p>
                        <p>复制邀请码</p>
                    </div>
                </div>
            </div>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="dialogCodeInvite = false">确 定</el-button>
        </span>
        </el-dialog>
        <!-- 邀请已有学员邀请码Dialog end-->

        <!-- 添加已有学员 -->
        <addStudents :max-length="60"  v-show="studentsAll" v-on:listenerAddStudent="handlerAddStudent"></addStudents>
        <!-- 添加已有学员 end--> 
    </div>
</template>
<script>
    // 引用 nav 组件 
    import adminHeader from '../components/adminHeader.vue';
    import addStudents from '../components/addStudents.vue'
    export default {
        components:{
            adminHeader:adminHeader,
            addStudents:addStudents
        },
        data() {
            return {
                // 单堂课程
                courseLists:[],
                studentsAll:false,
                // 队伍数组
                teamLists:[],
                // 性别
                sexLists:[
                    {value:'female',text:'女'},
                    {value:'male',text:'男'},
                ], 
                // 职位
                positionLists:[
                    {value:'1',text:'ceo'},
                    {value:'2',text:'ceo'},
                ], 
                // 批量导入学员Dialog
                dialogImport: false,
                // 导入的学员数据
                importStudentData: [],
                // 导入是否存在错误,默认无错误
                importHasError:false,
                // 导入失败提示
                promptsTip: false,
                // 学员导入失败Dialog
                dialogFailure: false,
                // 学员导入失败
                failureLists:[
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                ],
                // 学员手机号重复Dialog
                dialogRepeat: false,
                // 学员手机号重复
                repeatLists:[
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                ],
                //邀请已有学员Dialog
                dialogHasInvite: false,
                //邀请已有学员
                inviteLists:[
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                    {
                        phone:'15245635456',
                        name:'稳如兰',
                        age:'30',
                        sex:'女',
                        position:'ceo',
                    },
                ],
                //邀请已有学员邀请码Dialog
                dialogCodeInvite: false,
                //邀请已有学员邀请码
                inviteCodeNumber:'AGBG1234',
                inviteCode:'../../static/image/HOD.png',
            };
        },
        methods: {
            invite:function(){
                
                // 位置索引，记录错误应该所在的位置
                let positionArr = [];
                
                // 四层循环，外两层用来和内两层比较是否相同
                for(let a in this.teamLists){
                    for (let b in this.teamLists[a].memberLists){
                        if (this.teamLists[a].memberLists[b].inviteMemberMobile != '') {
                            // 错误数
                            let count = 0;
                            // 运行到这里时，这是是把所有有值的手机号找出来，和外层有值的手机号比较，如果存在相同且大于等于2，则视为重复
                            for(let c in this.teamLists){
                                for (let d in this.teamLists[c].memberLists){
                                    if (this.teamLists[c].memberLists[d].inviteMemberMobile != '') {
                                        if (this.teamLists[a].memberLists[b].inviteMemberMobile == this.teamLists[c].memberLists[d].inviteMemberMobile) {
                                            count++;
                                        }
                                    }
                                }
                            }
                            // 大于等于2，说明存在重复
                            if (count >= 2) {
                                // 这里用一个对象存储队伍索引和成员索引，可以理解为某个队伍某行成员的某个错误
                                let data = {
                                    teamIndex:a,
                                    memberIndex:b,
                                    errorText:'手机号码重复'
                                };
                                positionArr.push(data)
                            }
                        }
                    }
                }

                /******** 手机格式验证 start ********/
                let reg = /^[1][3,4,5,7,8][0-9]{9}$/; //格式正则表达式
                for(let i in this.teamLists){
                    for (let j in this.teamLists[i].memberLists){
                        if (this.teamLists[i].memberLists[j].inviteMemberMobile != '') {
                            // 验证手机格式
                            if (!reg.test(this.teamLists[i].memberLists[j].inviteMemberMobile)) {
                                let data = {
                                    teamIndex:i,
                                    memberIndex:j,
                                    errorText:'手机号码格式错误'
                                };
                                positionArr.push(data)
                            }
                        }
                    }
                }
                /******** 手机格式验证 end ********/

                console.log(positionArr)
                /******** 循环错误并且在相应位置显示错误 start ********/
                // 如果长度大于0说明是有错误的，不能调接口
                if (positionArr.length > 0) {
                    for (const key in positionArr) {
                        const element = positionArr[key];
                        document.getElementsByClassName('studentItem')[element.teamIndex].getElementsByClassName('emptyTip2')[element.memberIndex].innerHTML = element.errorText
                    }
                    return
                }

                let memberArr = [];
                for (const teamIndex in this.teamLists) {
                    for (const memberIndex in this.teamLists[teamIndex].memberLists) {
                        if (this.teamLists[teamIndex].memberLists[memberIndex].inviteMemberMobile != '') {
                            memberArr.push(this.teamLists[teamIndex].memberLists[memberIndex])
                        }
                    }
                }
                console.log(memberArr)
                
                /******** 循环错误并且在相应位置显示错误 end ********/

                let courseIdList = []
                // courseIdList.push(this.$route.params.id)
                // console.log(courseIdList)
                if (sessionStorage.getItem("courseArr") != null) {
                    courseIdList = JSON.parse(sessionStorage.getItem("courseArr"))
                }
                console.log(courseIdList)
                let data = {
                    userId: JSON.parse(sessionStorage.getItem("login")).id,
                    courseIdList: courseIdList,
                    inviteMemberModelList: memberArr
                }
                console.log(data)
                // this.$http.inviteMembers(data,(res)=>{

                // })
                this.$http.inviteMembers(data, (res)=>{
                    if(res.errCode == 0){
                        // 创建课程成功dialog
                        // this.successModal = true;
                        alert('ok')
                    }
                    console.log(res)
                },(errRes)=>{
                    console.log(errRes)
                })
              
            },
            //触发按钮事件
            // btnUploadClick:function(){
            //     document.getElementById('uploadImport').click() 
            // },
            //点击上传-文件上传成功后的钩子
            handleSuccess(response, file, fileList){
                console.log(response);
                console.log(file);
                if (response.errCode == 0) {
                    console.log('上传成功')
                } else {
                    console.log('上传失败')
                }
                this.importStudentData = response.data
            },
            //上传文件验证
            beforeAvatarUpload(file) {
                var testmsg=file.name.substring(file.name.lastIndexOf('.')+1)                 
                const extension = testmsg === 'xls'  
                const extension2 = testmsg === 'xlsx'  
                const isLt2M = file.size / 1024 / 1024 < 10  
                if(!extension && !extension2) {
                // 如果if进来，说明存在错误，赋值为true，后面只要判断如果为true就提示
                this.importHasError = true;
                this.promptsTip = true;
                    this.$message({  
                        message: '上传文件只能是 xls、xlsx格式!',  
                        type: 'error'  
                    });  
                }else{
                    this.promptsTip = false;
                }  
                if(!isLt2M) { 
                // 如果if进来，说明存在错误，赋值为true，后面只要判断如果为true就提示
                this.importHasError = true
                    this.$message({  
                        message: '上传文件大小不能超过 10MB!',  
                        type: 'error'  
                    });  
                } 
                return extension || extension2 && isLt2M  
            },
            //清除已上传的文件
            clearFiles(){
                 this.$refs.upload.clearFiles()
            },
            // submitUpload() {
            //     // console.log(this.$refs.upload)
            //     this.$refs.upload.submit();
            // },
            importStudent(){
                // 队伍循环，默认6组，后期修改，可以给此方法的第一个参数传入组数
                for (let teamIndex = 0; teamIndex < this.teamLists.length; teamIndex++) {
                    // 学员循环，默认每1组10人，共60人，后期修改，可以给此方法的第二个参数传入组数
                    for (let memberIndex = 0; memberIndex < this.teamLists[teamIndex].memberLists.length; memberIndex++) {
                        if (this.teamLists[teamIndex].memberLists[memberIndex].inviteMemberMobile == '') {
                            if (this.importStudentData.length > 0) {
                                let firstMemberObj = this.importStudentData.shift()
                                this.teamLists[teamIndex].memberLists[memberIndex].name = firstMemberObj.name
                                this.teamLists[teamIndex].memberLists[memberIndex].inviteMemberMobile = firstMemberObj.inviteMemberMobile
                                this.teamLists[teamIndex].memberLists[memberIndex].gender = firstMemberObj.gender
                                this.teamLists[teamIndex].memberLists[memberIndex].department = firstMemberObj.department
                                // this.teamLists[teamIndex].memberLists[memberIndex].position = 0 // 接口返回有问题，先默认设置为0
                                
                                let id = 'position'+teamIndex+memberIndex;
                                let positionSelect = document.getElementById(id);
                                let optionArr = positionSelect.getElementsByTagName('option');
                                // console.log(optionArr)
                                for (const key in optionArr) {
                                    if (optionArr[key].nodeType == 1) {
                                        const element = optionArr[key]
                                        if (element.innerHTML === firstMemberObj.positionName) {
                                            this.teamLists[teamIndex].memberLists[memberIndex].position = parseInt(element.value)
                                        }
                                    }
                                }
                                
                            }
                        }
                    }
                }
                // 关闭模态框
                this.dialogImport = false;
            },
            //已邀请学员Dialog
            hasInvite:function(){
                this.dialogHasInvite = false;
                this.dialogCodeInvite = true;
            },
            //获取部门
            department:function(){
                let data={}
                this.$http.getPosition(data,(res)=>{
                    if(res.errCode==0){
                        this.positionLists = res.data
                    }   
                })
            },
            // 页面初始化学员结构
            initMemberRender(teamNumber = 6, memberNumber = 10){
                // 队伍数组
                let teamArr = []
                // 学员序号
                let stuIndex = 1
                // 队伍循环，默认6组，后期修改，可以给此方法的第一个参数传入组数
                for (let teamIndex = 0; teamIndex < teamNumber; teamIndex++) {
                    // 学员数组
                    let memberArr = []
                    // 学员循环，默认每1组10人，共60人，后期修改，可以给此方法的第二个参数传入组数
                    for (let memberIndex = 0; memberIndex < memberNumber; memberIndex++) {
                        let memberObj = {
                            num: "学员" + stuIndex,
                            id: "",
                            name: "",
                            inviteMemberMobile: "",
                            gender: "",
                            department: "",
                            position: "",
                            courseId: "",
                            createTime: "",
                            createUser: "",
                            isDelete: "",
                            inviteStatus: "",
                        }
                        memberArr.push(memberObj)
                        stuIndex++;
                    }

                    let data = {
                        memberLists: []
                    }
                    data.memberLists = memberArr
                    teamArr.push(data)
                }

                console.log(teamArr)
                this.teamLists = teamArr
            },
            // 手机号失去焦点验证是否重复、格式是否错误
            blurValidator(inviteMemberMobile,teamLists,event){
                let count = 0;
                let nextTarget = event.target.nextElementSibling;

                for(let i in teamLists){
                    for (let j in teamLists[i].memberLists){
                        // 判断手机号码是否重复，重复则count+1
                        if (teamLists[i].memberLists[j].inviteMemberMobile == inviteMemberMobile && inviteMemberMobile != '') {
                            count++;
                            if (count >= 2) {
                                teamLists[i].memberLists[j].repeat = true
                            } else {
                                teamLists[i].memberLists[j].repeat = false
                            }
                        } 
                    }
                    
                }

                // 从这里开始，这里mobileArr为填写后的手机号数组，把所有填写的手机号存到一个数组里，一个手机号为一个成员，到时候只要统计这个数组长度就得出学员数量了
                let mobileArr = [];
                let teamTotalNum = 0;
                let reg = /^[1][3,4,5,7,8][0-9]{9}$/; //格式正则表达式

                /******** 把非空的值（手机号码）加入到一个数组中 start */
                for(let i in this.teamLists){
                    // 手机号是否为空
                    let mobileIsNotEmpty = false;
                    for (let j in this.teamLists[i].memberLists){
                        if (this.teamLists[i].memberLists[j].inviteMemberMobile != '' && reg.test(this.teamLists[i].memberLists[j].inviteMemberMobile) && this.teamLists[i].memberLists[j].repeat == false) {
                            mobileArr.push(this.teamLists[i].memberLists[j].inviteMemberMobile);
                            mobileIsNotEmpty = true;
                        }
                    }

                    if (mobileIsNotEmpty) {
                        teamTotalNum++;
                    }
                }
                /******** 把非空的值（手机号码）加入到一个数组中 end */
                console.log(teamTotalNum)
                console.log(mobileArr)
                // 基本验证
                if (inviteMemberMobile != '') {
                    if(!reg.test(inviteMemberMobile)){
                        nextTarget.innerHTML = '手机号码格式错误'
                        nextTarget.style.display= 'block'
                        this.hasError = true
                        this.hasErrorText = '手机号有错误，请检查填写信息'
                    } else if(count>=2){
                        nextTarget.innerHTML = '手机号码重复'
                        nextTarget.style.display= 'block'
                        this.hasError = true
                        this.hasErrorText = '手机号码重复，请检查手机号'
                    } else {
                        nextTarget.innerHTML = ''
                        nextTarget.style.background= 'none'
                        this.hasError = false
                        this.hasErrorText = ''
                    }
                } else {
                    nextTarget.innerHTML = '' // 这里是为了如果写了错误的手机号码，下面会有提示，删除手机号码还会存在，就在这里清空
                    nextTarget.style.background= 'none' // 同上
                }

                // this.confirmCreateCourse(1);
            },
            addStudents(){
                this.studentsAll = true
            },
            handlerAddStudent(v){
                console.log(v)
                // 队伍循环，默认6组，后期修改，可以给此方法的第一个参数传入组数
                for (let teamIndex = 0; teamIndex < this.teamLists.length; teamIndex++) {
                    // 学员循环，默认每1组10人，共60人，后期修改，可以给此方法的第二个参数传入组数
                    for (let memberIndex = 0; memberIndex < this.teamLists[teamIndex].memberLists.length; memberIndex++) {
                        if (this.teamLists[teamIndex].memberLists[memberIndex].inviteMemberMobile == '') {
                            if (v.length > 0) {
                                let firstMemberObj = v.shift()
                                this.teamLists[teamIndex].memberLists[memberIndex].name = firstMemberObj.name
                                this.teamLists[teamIndex].memberLists[memberIndex].inviteMemberMobile = firstMemberObj.mobile
                                this.teamLists[teamIndex].memberLists[memberIndex].gender = firstMemberObj.gender
                                this.teamLists[teamIndex].memberLists[memberIndex].department = ''
                                this.teamLists[teamIndex].memberLists[memberIndex].position = firstMemberObj.positionId
                                
                            }
                        }
                    }
                }
                console.log(this.teamLists)

                this.studentsAll = false
            }
        },
        computed: {

        },
        created() {

        },
        mounted() {
            // 初始化页面学员结构
            this.initMemberRender();
            // 获取上页面传来的数据并赋值
            // this.courseLists = JSON.parse(sessionStorage.getItem("data"))
            // console.log(JSON.parse(sessionStorage.getItem("courseArr")))

            console.log(JSON.parse(sessionStorage.getItem("courseArr")))
            let data = {
                courseIdList: JSON.parse(sessionStorage.getItem("courseArr"))
            }
            this.$http.inviteCourseList(data, (successRes)=>{
                console.log(successRes)
                if (successRes.errCode == 0) {
                    this.courseLists = successRes.data
                }
            },(errorRes)=>{
                console.log(errorRes)
            });

            // 获取部门
            this.department();
        }
    };
</script>
